package com.china_goldcard.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

/**
 * 基础的PagerAdapter
 */

public class MyBasePageAdapter<T extends View> extends PagerAdapter {

    private List<T> views = new ArrayList<T>();

    public MyBasePageAdapter(List<T> views) {
        this.views = views;
    }

    @Override
    public boolean isViewFromObject(View arg0,Object arg1){
        return arg0 == arg1;
    }

    @Override
    public int getCount(){
        return views.size ();
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(views.get(position));
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        T view = views.get(position);
        container.addView(view);
        return view;
    }
}
